<?php
defined('IN_PHPCMS') or exit('No permission resources.');
/**
 * 点击统计
 */
$db = pc_base::load_model('news_model');//需要先新建一个news_model
$id = intval($_GET['id']);
if (isset($id) && !empty($id)) {
    $r = $db->get_one(array('id' => $id), 'real_hit,fake_hit');
    $old_real_hit = $r['real_hit'];
    $old_fake_hit = $r['fake_hit'];

    $old_real_hit = empty($old_real_hit) ? 0 : $old_real_hit;
    $old_fake_hit = empty($old_fake_hit) ? 0 : $old_fake_hit;
    $real_hit = $old_real_hit + 1;
    $fake_hit = $old_fake_hit + rand(10, 100);

    return $db->update(array('real_hit' => $real_hit, "fake_hit" => $fake_hit), array('id' => $id));
}